export default function imageToBase64(imageUrl,delHeader = true) {
    return new Promise((resolve, reject) => {
      var img = new Image();
      img.crossOrigin = 'Anonymous';
      img.onload = function() {
        var canvas = document.createElement('canvas');
        canvas.width = img.width;
        canvas.height = img.height;
        var ctx = canvas.getContext('2d');
        ctx.drawImage(img, 0, 0);
        var base64 = canvas.toDataURL();
        if(delHeader) base64 = base64.replace(/^data:image\/\w+;base64,/, '');
        resolve(base64)
      };
      img.src = imageUrl;
  })
}